package com.treasure.service.tally.controller;

import com.treasure.service.annotation.LogInfo;
import com.treasure.service.tally.service.TallyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
* @Description:    返佣记账
* @Author:         panxinwen
* @CreateDate:     2018/11/6 22:10
* @Version:        1.0
*/
@Api(value = "返佣记账",description = "客户办理信用卡及邀请返佣记账")
@RestController
@RequestMapping("/tally/v1")
public class TallyController {

    @Autowired
    private TallyService tallyService;

    @LogInfo(log = "返佣记账")
    @ApiOperation(value = "返佣记账",notes = "返佣记账")
    @PostMapping("/tally")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type", value = "类型（1：自己办卡返佣 2邀请会员返佣 3邀请他人办卡返佣 4下级邀请办卡返佣）",required = true,dataType = "int",paramType = "query"),
            @ApiImplicitParam(name = "amount", value = "交易金额",required = true,dataType = "int",paramType = "query"),
            @ApiImplicitParam(name = "userId", value = "userId",required = true,dataType = "Long",paramType = "query"),
            @ApiImplicitParam(name = "orderId", value = "订单编号",required = true,dataType = "Long",paramType = "query"),

    })
    public ResponseEntity tally(
            @RequestParam(value = "type", required = true) Integer type,
            @RequestParam(value = "amount", required = true) Long amount,
            @RequestParam(value = "userId", required = true) Long userId,
            @RequestParam(value = "orderId", required = true) Long orderId){

        Integer s = tallyService.tally(type,amount,userId,orderId);

        return ResponseEntity.ok(s);

    }

}
